/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufrn.adurn.architecture.dao;

import br.ufrn.adurn.domain.Pensao;
import java.sql.PreparedStatement;
import java.sql.Connection;
import java.sql.SQLException;

/**
 *
 * @author Victor
 */
public class PensaoDAO {

    private Connection connection;

    public PensaoDAO() {
        this.connection = new ConnectionFactory().getConnection();
    }

    public void adiciona(Pensao pensao) {
        String sql = "INSERT INTO pensao (id_prof,id_pens) values (?,?)";
        try {
            PreparedStatement stmt = connection.prepareStatement(sql);
            stmt.setLong(1, pensao.getIdProfessor());
            stmt.setLong(2, pensao.getIdPensionista());
            stmt.execute();
            stmt.close();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        System.out.println("TUDO OK COM A PENSAO");
    }
}
